﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;

namespace YShop.Core.Entites.Shop
{
    /// <summary>
    /// 产品属性
    /// </summary>
    public class ProductAttribute : BaseEntity, IEntitySeedData<ProductAttribute>
    {
        /// <summary>
        /// 编号
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 选项 
        /// </summary>
        public List<ProductAttributeItem> Items { get; set; }
        /// <summary>
        /// 选项连接
        /// </summary>
        [Column(TypeName = "text")]
        public string ItemJoin { get; set; }

        public IEnumerable<ProductAttribute> HasData(DbContext dbContext, Type dbContextLocator)
        {
            return new List<ProductAttribute> 
            {
                new ProductAttribute
                { 
                    Code = "A0001",
                    Id = "60435ff9-1293-0b00-0085-31265720eaa2",
                    Name = "颜色",
                }
            };
        }
    }

    /// <summary>
    /// 选项子项
    /// </summary>
    public class ProductAttributeItem : OnlyPrimaryEntity, IEntitySeedData<ProductAttributeItem>
    {
        /// <summary>
        /// 属性ID
        /// </summary>
        public string ProductAttributeId { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 参数
        /// </summary>
        public string Params { get; set; }

        public IEnumerable<ProductAttributeItem> HasData(DbContext dbContext, Type dbContextLocator)
        {
            return new List<ProductAttributeItem> 
            {
                new ProductAttributeItem { Id = "6043629a-370b-e14c-00ee-551d16c31868", Name = "红", ProductAttributeId = "60435ff9-1293-0b00-0085-31265720eaa2" },
                new ProductAttributeItem { Id = "604362c9-370b-e14c-00ee-551e5d44baea", Name = "黄", ProductAttributeId = "60435ff9-1293-0b00-0085-31265720eaa2" },
                new ProductAttributeItem { Id = "604362d3-370b-e14c-00ee-551f21dd3921", Name = "蓝", ProductAttributeId = "60435ff9-1293-0b00-0085-31265720eaa2" },
                new ProductAttributeItem { Id = "604362dd-370b-e14c-00ee-55202daadad1", Name = "黑", ProductAttributeId = "60435ff9-1293-0b00-0085-31265720eaa2" },
                new ProductAttributeItem { Id = "604362e6-370b-e14c-00ee-5521547a322c", Name = "灰", ProductAttributeId = "60435ff9-1293-0b00-0085-31265720eaa2" },
            };
        }
    }
}
